﻿using EFCORE仓储模式.Contracts;
using Microsoft.AspNetCore.Mvc;

namespace EFCORE仓储模式.Controllers
{
    [Route("api/player")]
    [ApiController]
    public class PlayerController(IRepositoryWrapper repository, ILogger<PlayerController> logger) : ControllerBase
    {
        [HttpGet]
        public async Task<IActionResult> GetAllPlayers()
        {
            try
            {
                var players = await repository.Player.GetAllPlayers();

                return Ok(players);
            }
            catch (Exception ex)
            {
                logger.LogError($"{ex.Message}");
                return StatusCode(500);
            }
        }
    }
}